import plotly.offline as pyo
from plotly.graph_objs import *
import chart_studio.plotly as py
import pandas as pd
from pandas import DataFrame
from plotly import tools
pyo.offline.init_notebook_mode()
iris = pd.read_csv(r"../Data/irisDataset.csv", index_col=0)
irisSpeciesUnique = list(iris['Species'].unique())
colours = ['green','blue','orange']
colourLookup = dict(zip(irisSpeciesUnique, colours))
fig = tools.make_subplots(rows=4, cols=4, print_grid=True)
for i, column in enumerate(iris.columns[:-1]):
for j, row in enumerate(iris.columns[:-1]):
if column != row:
for species, colour in colourLookup.items():
fig.append_trace({'type' : 'scatter',
'mode' : 'markers',
'x' : iris.loc[iris['Species'] == species, column],
'y' : iris.loc[iris['Species'] == species, row],
'marker' : {'color' : colour},
'name' : species},
col = i + 1, row = j + 1)
pyo.iplot(fig)
/Users/josh/opt/anaconda3/lib/python3.9/site-packages/plotly/tools.py:460: DeprecationWarning: plotly.tools.make_subplots is deprecated, please use plotly.subplots.make_subplots instead
This is the format of your plot grid: [ (1,1) x,y ] [ (1,2) x2,y2 ] [ (1,3) x3,y3 ] [ (1,4) x4,y4 ] [ (2,1) x5,y5 ] [ (2,2) x6,y6 ] [ (2,3) x7,y7 ] [ (2,4) x8,y8 ] [ (3,1) x9,y9 ] [ (3,2) x10,y10 ] [ (3,3) x11,y11 ] [ (3,4) x12,y12 ] [ (4,1) x13,y13 ] [ (4,2) x14,y14 ] [ (4,3) x15,y15 ] [ (4,4) x16,y16 ]
ig = tools.make_subplots(rows = 4, cols = 4, print_grid = True)
for i, column in enumerate(iris.columns[:-1]):
for j, row in enumerate(iris.columns[:-1]):
if column != row:
if i == 0 and j == 1:
show = True
else:
show = False
for species, colour in colourLookup.items():
fig.append_trace({'type' : 'scatter',
'mode' : 'markers',
'x' : iris.loc[iris['Species'] == species, column],
'y' : iris.loc[iris['Species'] == species, row],
'marker' : {'color' : colour,
'size' : 3},
'name' : species,
'legendgroup' : species,
'showlegend' : show},
col = i + 1, row = j + 1)
pyo.iplot(fig)
This is the format of your plot grid: [ (1,1) x,y ] [ (1,2) x2,y2 ] [ (1,3) x3,y3 ] [ (1,4) x4,y4 ] [ (2,1) x5,y5 ] [ (2,2) x6,y6 ] [ (2,3) x7,y7 ] [ (2,4) x8,y8 ] [ (3,1) x9,y9 ] [ (3,2) x10,y10 ] [ (3,3) x11,y11 ] [ (3,4) x12,y12 ] [ (4,1) x13,y13 ] [ (4,2) x14,y14 ] [ (4,3) x15,y15 ] [ (4,4) x16,y16 ]
fig = tools.make_subplots(rows = 4, cols = 4, print_grid = True, shared_xaxes = True, shared_yaxes = True)
for i, column in enumerate(iris.columns[:-1]):
for j, row in enumerate(iris.columns[:-1]):
if column != row:
if i == 0 and j == 1:
show = True
else:
show = False
for species, colour in colourLookup.items():
fig.append_trace({'type' : 'scatter',
'mode' : 'markers',
'x' : iris.loc[iris['Species'] == species, column],
'y' : iris.loc[iris['Species'] == species, row],
'marker' : {'color' : colour,
'size' : 3},
'name' : species,
'legendgroup' : species,
'showlegend' : show},
col = i + 1, row = j + 1)
pyo.iplot(fig)
This is the format of your plot grid: [ (1,1) x,y ] [ (1,2) x2,y2 ] [ (1,3) x3,y3 ] [ (1,4) x4,y4 ] [ (2,1) x5,y5 ] [ (2,2) x6,y6 ] [ (2,3) x7,y7 ] [ (2,4) x8,y8 ] [ (3,1) x9,y9 ] [ (3,2) x10,y10 ] [ (3,3) x11,y11 ] [ (3,4) x12,y12 ] [ (4,1) x13,y13 ] [ (4,2) x14,y14 ] [ (4,3) x15,y15 ] [ (4,4) x16,y16 ]
fig = tools.make_subplots(rows = 4, cols = 4, print_grid = True, shared_xaxes = True, shared_yaxes = True)
for i, column in enumerate(iris.columns[:-1]):
fig['layout']['xaxis{}'.format(i + 1)].update({'title' : column + " (cm)",
'range' : [0, max(iris[iris.columns[:-1]].max())]})
for j, row in enumerate(iris.columns[:-1]):
fig['layout']['yaxis{}'.format(j + 1)].update({'title' : row + " (cm)",
'range' : [0, max(iris[iris.columns[:-1]].max())]})
if column != row:
if i == 0 and j == 1:
show = True
else:
show = False
for species, colour in colourLookup.items():
fig.append_trace({'type' : 'scatter',
'mode' : 'markers',
'x' : iris.loc[iris['Species'] == species, column],
'y' : iris.loc[iris['Species'] == species, row],
'marker' : {'color' : colour,
'size' : 3},
'name' : species,
'legendgroup' : species,
'showlegend' : show},
col = i + 1, row = j + 1)
pyo.iplot(fig)
This is the format of your plot grid: [ (1,1) x,y ] [ (1,2) x2,y2 ] [ (1,3) x3,y3 ] [ (1,4) x4,y4 ] [ (2,1) x5,y5 ] [ (2,2) x6,y6 ] [ (2,3) x7,y7 ] [ (2,4) x8,y8 ] [ (3,1) x9,y9 ] [ (3,2) x10,y10 ] [ (3,3) x11,y11 ] [ (3,4) x12,y12 ] [ (4,1) x13,y13 ] [ (4,2) x14,y14 ] [ (4,3) x15,y15 ] [ (4,4) x16,y16 ]
fig['layout'].update({'title' : 'Length and width of sepals and petals for Iris supspecies', 'height' : 1000})
pyo.iplot(fig)